package com.qidian.buy.search.controller;

import com.qidian.buy.search.service.SearchService;
import com.qidian.buy.util.Constant;
import com.qidian.buy.util.pojo.BuyResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Author: 戴着假发的程序员
 * Date: 2023-07-11 13:58
 * company: 起点编程
 * Description:
 **/
@RestController
@RequestMapping("/buy/search")
@CrossOrigin
public class SearchController {
    @Autowired
    private SearchService searchService;

    @GetMapping(value="/importIndex",produces = "application/json;charset=utf-8")
    public BuyResult importIndex(){
        return searchService.importIndex();
    }

    @GetMapping(value = "/s",produces = Constant.CONTENT_TYPE_JSON_UTF8)
    public BuyResult s(@RequestParam(defaultValue = "1")int page,@RequestParam(defaultValue = "60")int limit,String kw){
        return searchService.search(page,limit,kw);
    }
}
